﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Kaidou.Persister;
using Kaidou.Model;
using Kaidou.Util;

public partial class seal_seal_order_detail_kumi : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginModel loginModel = (LoginModel)Session["loginModel"];
        if (loginModel == null)
        {
            Response.Redirect("../login.aspx");
        }
        else if (!loginModel.isKumiaiin())
        {
            Response.Redirect("../menu.aspx");
        }

        if (loginModel.isKumiaiin() && sessioncontrol.control())
        {
            Response.Redirect("../control.aspx");
        }

        try
        {

            Order order = new Order();
            TRN_Juchu_HPersister parJ = new TRN_Juchu_HPersister();
            TRN_Juchu_DPersister parD = new TRN_Juchu_DPersister();
            string juchu_no=Request.QueryString["juchu_no"].ToString();

            order.setJuchu_H(parJ.getDetail(juchu_no));
            order.setJuchu_D(parD.getDetail(juchu_no));

            Session["order"] = order;
            Unioncode.Text = order.getJuchu_H().UnionCode;

            MST_UnionPersister dao1 = new MST_UnionPersister();
            MST_Union_BranchPersister dao2 = new MST_Union_BranchPersister();
            
            ParentOfficeName.Text = dao1.getDetail(order.getJuchu_H().UnionCode).OfficeName;

            mst_union_branch branch = dao2.getDetail(order.getJuchu_H().UnionCode, order.getJuchu_H().BranchCode);
            BranchOfficeName.Text = branch == null ? "000 本店" : String.Format("{0:D3} ", branch.Id.branchcode) + " " + branch.officename;

            TRN_JUCHU_TANTO_NAME.Text = order.getJuchu_H().JuchuTantoName;

        }
        catch (Exception ex)
        {

            LogManager.error("seal_seal_order_detail_kumi " + ex.Message);
        }
    }
}
